package com.proxy.common.model;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liufish on 16/12/11.
 */
public class ProxyTable {

    String name;

    String alias;

    String db;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getDb() {
        return db;
    }

    public void setDb(String db) {
        this.db = db;
    }

    public static final class Column {

        private String columnName;

        private String tableName;

        private boolean where;
        private boolean select;
        private boolean groupBy;
        private boolean having;
        private boolean join;


        public String getColumnName() {
            return columnName;
        }

        public void setColumnName(String columnName) {
            this.columnName = columnName;
        }

        public String getTableName() {
            return tableName;
        }

        public void setTableName(String tableName) {
            this.tableName = tableName;
        }

        public boolean isWhere() {
            return where;
        }

        public void setWhere(boolean where) {
            this.where = where;
        }

        public boolean isSelect() {
            return select;
        }

        public void setSelect(boolean select) {
            this.select = select;
        }

        public boolean isGroupBy() {
            return groupBy;
        }

        public void setGroupBy(boolean groupBy) {
            this.groupBy = groupBy;
        }

        public boolean isHaving() {
            return having;
        }

        public void setHaving(boolean having) {
            this.having = having;
        }

        public boolean isJoin() {
            return join;
        }

        public void setJoin(boolean join) {
            this.join = join;
        }
    }

    public static class Condition {

        private Column column;

        private String operator;

        private List<Object> values = new ArrayList<Object>();

        public Column getColumn() {
            return column;
        }

        public void setColumn(Column column) {
            this.column = column;
        }

        public String getOperator() {
            return operator;
        }

        public void setOperator(String operator) {
            this.operator = operator;
        }

        public List<Object> getValues() {
            return values;
        }

        public void setValues(List<Object> values) {
            this.values = values;
        }
    }


    public static class Relationship {

        private Column left;

        private Column right;

        private String operator;

        public Column getLeft() {
            return left;
        }

        public void setLeft(Column left) {
            this.left = left;
        }

        public Column getRight() {
            return right;
        }

        public void setRight(Column right) {
            this.right = right;
        }

        public String getOperator() {
            return operator;
        }

        public void setOperator(String operator) {
            this.operator = operator;
        }
    }


    public enum Operator {

        EQUAL("="),

        BETWEEN("BETWEEN"),

        NOT_IN("NOT IN"),

        IN("IN");

        private String expression;

        Operator(String expression) {
            this.expression = expression;
        }


    }


    public static class Limit{

        private int offset;

        private int rowCount;

        public int getOffset() {
            return offset;
        }

        public void setOffset(int offset) {
            this.offset = offset;
        }

        public int getRowCount() {
            return rowCount;
        }

        public void setRowCount(int rowCount) {
            this.rowCount = rowCount;
        }
    }


}
